using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter25
{
	/// <summary>
	/// Example03: The Electric Potential Due to Two Point Charges.
	/// A charge q_1 = 2.00 \mu C is located at the origin, and 
	/// a charge q_2 = -6.00 \mu C is located at (0,3.00)m, as shown 
	/// in Figure 25.12a. 
	/// (A) 
	/// Find the total electric potential due to these charges 
	/// at the point P, whose coordinates are (4.00, 0) m. 
	/// V_P = -6.29 \times 10^3 V
	/// (B) 
	/// Find the change in potential energy of the system of 
	/// two charges plus a charge q_3 = 3.00 \mu C as the latter charge 
	/// moves from infinity to point P (Fig.25.12b) 
	/// \Delta U = -1.89 \times 10^{-2} J
	/// </summary>
	public class Example03
	{
		public Example03()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.ElectricCharge q1 = new L.ElectricCharge();
			q1.C = 2.0E-6;
			L.Position A = new L.Position();
			A.X = 0.0;
			A.Y = 0.0;
			A.Z = 0.0; 
			L.ElectricCharge q2 = new L.ElectricCharge();
			q2.C = -6.0E-6;
			L.Position B = new L.Position();
			B.X = 0.0;
			B.Y = 3.0;
			B.Z = 0.0;

			L.Position P = new L.Position();
			P.X = 4.0;
			P.Y = 0.0;
			P.Z = 0.0;

			L.ElectricPotential V1
				= new L.ElectricPotential(q1,A,P);
			L.ElectricPotential V2
				= new L.ElectricPotential(q2,B,P);
			L.ElectricPotential VP
				= new L.ElectricPotential();
			VP.V = V1.V + V2.V;
			//(A)
			result+=Convert.ToString(VP.V)+"\r\n";
			//(B)
			L.ElectricCharge q3 = new L.ElectricCharge();
			q3.C = 3.0E-6;
			L.PotentialEnergy U = new L.PotentialEnergy(q3,VP);
			result+=Convert.ToString(U.J)+"\r\n";
			
		}
	}
}
